package com.isoftstone.service.impl;

import com.isoftstone.dao.JobMapper;
import com.isoftstone.pojo.Job;
import com.isoftstone.pojo.JobExample;
import com.isoftstone.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobMapper jobMapper;

    public int add(Job job) {
        return jobMapper.insertSelective(job);
    }

    @Override
    public List<Job> queryAll() {

        // 查询所有
        return jobMapper.selectByExample(null);
    }

    @Override
    public Job queryById(Integer id) {

        Job job = jobMapper.selectByPrimaryKey(id);
        return job;
    }

    @Override
    public void deleteById(Integer id) {
        jobMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByJob(Job newjob, Integer id) {
        JobExample jobExample = new JobExample();
        jobExample.createCriteria().andIdEqualTo(id);
        return jobMapper.updateByExampleSelective(newjob, jobExample);
    }

    @Override
    public List<Job> queryByIsstock(Boolean Isstock) {
        JobExample jobExample = new JobExample();
        jobExample.createCriteria().andIsstockEqualTo(Isstock);
        List<Job> jobs = jobMapper.selectByExample(jobExample);
        return jobs;
    }
}
